Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename set_roles to with_roles and add support for declared_attr and column properties #140

Merged
merged 2 commits into from
Aug 31, 2017

Conversation

jace
Copy link
Member

@jace jace commented Aug 30, 2017

Fixes #139 and addresses the concerns raised in #138.

…column properties

Fixes #139 and addresses the concerns raised in #138.
@jace
Copy link
Member Author

jace commented Aug 31, 2017

I suspect there's a better way to do this. Instead of putting the value in a temporary cache, it could be wrapped in a descriptor which does the magic when it becomes affiliated with a class.

@jace
Copy link
Member Author

jace commented Aug 31, 2017

The descriptor approach—if it is at all feasible—won't work with the set_roles syntax, as that explicitly marks up the object passed to it rather than wrapping it.

title = db.Column(db.Unicode(250))
set_roles(title, read={'all'})

Will need to change to:

title = db.Column(db.Unicode(250))
title = with_roles(title, read={'all'})

While this is currently valid syntax (it looks odd here but makes sense for properties), it means the set_roles syntax needs explicit deprecation.

@jace
Copy link
Member Author

jace commented Aug 31, 2017

The descriptor trick was a guess based on the __set_name__ call, but it only works since Python 3.6. Not usable in Coaster which maintains 2.7 compatibility.

@jace jace merged commit e38bd0b into master Aug 31, 2017
@jace jace deleted the rolemixin-updates branch August 31, 2017 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant